/**
 * 
 */
package org.shark.jdbcTemplateTool.utils.sql;

import org.shark.jdbcTemplateTool.exception.SqlFormatException;

/**
 * @author lenovo
 * @description
 * @date 2016年8月17日
 */
public class SqlLoadFactory {

	public LoadType loadType;

    private String cacheName;
    
    private SqlLoad load;
    
	private static class SingletonClassInstant {
		private static final SqlLoadFactory instant = new SqlLoadFactory();
	}

	public static SqlLoadFactory getInstant() {
		return SingletonClassInstant.instant;
	}

    
	public void init() throws SqlFormatException {
		switch (loadType) {
    		case XML:
    			load = SqlXmlUtil.newInstance;
    			break;
    		case SQL:
    			load = SqlFileUtil.newInstance;
    			break;
    		default:
    			load = SqlFileUtil.newInstance;
    			break;
		}
		load.init(true, cacheName);
	}
	
	public SqlLoad getLoad() {
		return load;
	}

	public LoadType getLoadType() {
		return loadType;
	}

	public void setLoadType(LoadType loadType) {
		this.loadType = loadType;
	}

    public String getCacheName() {
        return cacheName;
    }

    public void setCacheName(String cacheName) {
        this.cacheName = cacheName;
    }

	public enum LoadType {
		XML, SQL
	}
}
